<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-form-item">
                            <label class="layui-form-label">按任务查询:</label>
                            <div class="layui-input-inline">
                                <select name="taskAndTime" lay-verify="">

                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block" style="float: left;">
                            <button class="layui-btn queryTask" lay-filter="sreach" type="button">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="signTable" lay-filter="signTable"></table>
                    <!--<script type="text/html" id="signData">
                        <div class="layui-btn-container">
                            <button class="layui-btn addSign"><i class="layui-icon">&#xe654;</i>添加任务</button>
                        </div>
                    </script>-->

                    <script type="text/html" id="signBar">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑(待)</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除(待)</a>
                    </script>

                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>layui.use('laydate',
    function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

    });</script>
<script>layui.use('table',
    function () {
        var table = layui.table;

        layui.use(['table','form'], function () {
            table = layui.table
            form = layui.form

            var url="/admin/queryLast"

            $(".queryTask").click(function () {
                var taskId=$("select[name='taskAndTime'] option:selected").val()
                url="/admin/queryLastById?taskId="+taskId
                query(url);
                form.render();
            })

            query(url);
            function query(url){
                table.render({
                elem: '#signTable'
                , url: url
                , toolbar: '#signData' //开启头部工具栏，并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                    title: '提示'
                    , layEvent: 'LAYTABLE_TIPS'
                    , icon: 'layui-icon-tips'
                }]
                , page: true
                , title: '打卡数据表'
                , curr: 1
                , limit: 15
                , limits: [5, 8, 10, 12, 14]
                , cols: [[
                    /*{type: 'checkbox', fixed: 'left'}*/
                    {field: 'stuId', title: '学生id', width: 100, fixed: 'left', unresize: true, sort: true}
                    , {field: 'stuName', title: '学生名称', width: 200}
                    , {field: 'taskName', title: '任务名称', width: 150}
                    , {field: 'taskContent', title: '任务内容', width: 450}
                    , {field: 'taskAdmin', title: '发布者', width: 180}
                    , {field: 'taskAndTime', title: '任务结束', width: 180}
                    , {
                        field: 'flagTask', title: '是否打卡', width: 150, templet: function (res) {
                            return res.flagTask == false ? '<em>未打卡</em>' : '<em>已打卡</em>'
                        }
                    }
                    , {fixed: 'right', title: '操作', toolbar: '#signBar', width: 200}
                ]]
            });
                form.render();
            }


          $.ajax({
              type:"get",
              url:"/admin/tasks",
              data:{
                  page:1,
                  limit:10000
              },
              dataType:"json",
              success:function (res) {

                  $.each(res.data,function (index,item) {
                      var strHtml="<option value="+item.taskId+">"+item.taskName+"</option>"
                      $("select[name='taskAndTime']").prepend(strHtml)
                  })
                    form.render();
              }

          })




        });




    });</script>


</html>